<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,user-scalable=no" />
<title>Document</title>
<style type="text/css">
	#box {
		font-size: 50px;
	}
</style>
</head>
<body>
<div id="box"></div>
<script type="text/javascript">
	var box = document.querySelector('#box');
	window.addEventListener('deviceorientation', function(e){
		var alpha = Math.round(e.alpha); // 0 - 360;
		var beta = Math.round(e.beta); // -180 - 180
		var gamma = Math.round(e.gamma);// -90 - 90
		box.innerHTML = gamma;
	});
</script>
</body>
</html>